//
//  Team9FaceViewController.m
//  Team9Project
//
//  Created by 朱嘉祺 on 15/10/21.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "Team9FaceViewController.h"
#import "Team9ExpertFaceCell.h"
#import "Team9JQHeader.h"

@interface Team9FaceViewController ()<UITableViewDataSource, UITableViewDelegate>


@end

@implementation Team9FaceViewController
- (void)setArray:(NSArray *)array{
    if (_array != array) {
        _array = array;
        [self.tableView reloadData];
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 64, 0);
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:_tableView];
    self.tableView.rowHeight = 40.0f * WIDTH / 375 + 20;
    self.tableView.tableFooterView = [Team9BaseView new];
    [self createData];
    self.empty = [Team9EmptyTool toolWithScrollView:self.tableView];
}
#pragma mark 申请数据
- (void)createData{
    self.tool = [Team9RefreshTool toolWithScrollView:self.tableView url:self.url style:^NSArray *(id result) {
        return [Team9ExpertUserModel baseModelByArr:result[@"data"][@"user_home_following_list"][@"users"]];
    } refresh:^(NSArray *array) {
        self.array = array;
    } empty:self.empty];
}
#pragma mark tableView methods for protols
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *reuse = @"faceReuse";
    Team9ExpertFaceCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[Team9ExpertFaceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];
    }
    cell.vc = self;
    cell.model = self.array[indexPath.row];
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
